package com.qy.util;


public class SystemParamsUtil {
	/**
	 * 存在redis中的key值
	 */
	
	/**
	 * 获取系统Integer参数
	 * @param key
	 * @return
	 */
	public static int getIntParam(String key){
		int tmp = StaticData.no_param;
		Object tmpO = RedisPoolMgr.hashGet(StaticData.REDISKEY.BS_S_PARAMS.toString(), key);
		if(tmpO!=null){
			tmp = Integer.parseInt(tmpO.toString()) ;
		}
		return tmp;
	}
	
	/**
	 * 获取系统Integer参数
	 * @param key
	 * @return
	 */
	public static Double getDoubleParam(String key){
		double tmp = StaticData.no_param;
		Object tmpO = RedisPoolMgr.hashGet(StaticData.REDISKEY.BS_S_PARAMS.toString(), key);
		if(tmpO!=null){
			tmp = Double.parseDouble(tmpO.toString()) ;
		}
		return tmp;
	}
	
	/**
	 * 获取系统String参数
	 * @param key
	 * @return
	 */
	public static String getStringParam(String key){
		String tmp = null;
		Object tmpO = RedisPoolMgr.hashGet(StaticData.REDISKEY.BS_S_PARAMS.toString(), key);
		if(tmpO!=null){
			tmp =  tmpO.toString();
		}
		return tmp;
	}
	
	
	
	/**
	 * 公众平台设置的微信号
	 * @return
	 * @throws Exception
	 */
	public static String getWeiXinNo()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("WEI_XIN_NO");
		if(tmp==null){
			throw new Exception("公众平台设置的微信号");
		}
		return tmp;
	}
	
	/**
	 * 微信公众号的appId
	 * @return
	 * @throws Exception
	 */
	public static String getAppIdD()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("APP_ID_D");
		if(tmp==null){
			throw new Exception("微信公众号的appId");
		}
		return tmp;
	}
	
	/**
	 * 微信公众号的密匙
	 * @return
	 * @throws Exception
	 */
	public static String getAppSecretD()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("APP_SECRET_D");
		if(tmp==null){
			throw new Exception("微信公众号的密匙");
		}
		return tmp;
	}
	
	/**
	 * 微信公众号的appId
	 * @return
	 * @throws Exception
	 */
	public static String getAppIdU()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("APP_ID_U");
		if(tmp==null){
			throw new Exception("微信公众号的appId");
		}
		return tmp;
	}
	
	/**
	 * 微信公众号的密匙
	 * @return
	 * @throws Exception
	 */
	public static String getAppSecretU()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("APP_SECRET_U");
		if(tmp==null){
			throw new Exception("微信公众号的密匙");
		}
		return tmp;
	}
	/**
	 * 微信公众号的token
	 * @return
	 * @throws Exception
	 */
	public static String getAppToken()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("TOKEN");
		if(tmp==null){
			throw new Exception("微信公众号的token");
		}
		return tmp;
	}
	
	/**
	 * 微信公众号的GRANT_TYPE
	 * @return
	 * @throws Exception
	 */
	public static String getGrantType()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("GRANT_TYPE");
		if(tmp==null){
			throw new Exception("微信公众号的GRANT_TYPE");
		}
		return tmp;
	}
	
	/**
	 * 后台用户的初始密码
	 * @return
	 * @throws Exception
	 */
	public static String getManageInitPwd() throws Exception{
		String tmp = SystemParamsUtil.getStringParam("MANAGE_INIT_PWD");
		if(tmp==null){
			throw new Exception("后台用户的初始密码");
		}
		return tmp;
	}
	
	/**
	 * 缓存保存的时间（小时）
	 * @return
	 * @throws Exception
	 */
	public static int getCACHE_TIME(){
		int tmp = SystemParamsUtil.getIntParam("CACHE_TIME");
		if(tmp==StaticData.no_param){
			LogUtil.error(("缓存保存的时间（小时）"));
		}
		return tmp;
	}
	
	/**
	 * 系统存储间隔时间（分钟）
	 * @return
	 * @throws Exception
	 */
	public static int getSYS_R_TIME(){
		int tmp = SystemParamsUtil.getIntParam("SYS_R_TIME");
		if(tmp==StaticData.no_param){
			LogUtil.error(("系统存储间隔时间（分钟）"));
		}
		return tmp;
	}
	
	/**
	 * 获取本地加密参数
	 * @return
	 * @throws Exception
	 */
	public static String getLocalMsgSecret()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("MY_MSG_SECRET");
		if(tmp==null){
			throw new Exception("本地密码获取失败");
		}
		return tmp;
	}
	

	

		
	/**
	 * 二维码生成地址
	 * @return
	 * @throws Exception
	 */
	public static String IMG_SERVICE_URL()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("IMG_SERVICE_URL");
		if(tmp==null){
			throw new Exception("服务器域名");
		}
		return tmp;
	}
	
	/**
	 * 后端工程名
	 * @return
	 * @throws Exception
	 */
	public static String SERVICE_NAME()  throws Exception{
		String tmp = SystemParamsUtil.getStringParam("SERVICE_NAME");
		if(tmp==null){
			throw new Exception("后端工程名");
		}
		return tmp;
	}
	
	/**
	 * 微信证书地址
	 * @return
	 * @throws Exception
	 */
	public static String getWXCertUrl() throws Exception{
		String tmp = SystemParamsUtil.getStringParam("WX_CERT_URL");
		if(tmp==null){
			throw new Exception("代理登录的跳转url");
		}
		return tmp;
	}
	
	/**
	 * 获取商户id
	 * @return
	 * @throws Exception
	 */
	public static String getMchID() throws Exception{
		String tmp = SystemParamsUtil.getStringParam("MCH_ID");
		if(tmp==null){
			throw new Exception("获取商户id");
		}
		return tmp;
	}
	
	/**
	 * 获取充值密匙
	 * @return
	 * @throws Exception
	 */
	public static String getWXRecharegeKey() throws Exception{
		String tmp = SystemParamsUtil.getStringParam("WX_RECHARGE_KEY");
		if(tmp==null){
			throw new Exception("获取充值密匙");
		}
		return tmp;
	}
	
	
	/**
	 * 微信充值回调地址
	 * @return
	 * @throws Exception
	 */
	public static String getWXNotifyUrl() throws Exception{
		String tmp = SystemParamsUtil.getStringParam("WX_NOTIFY_URL");
		if(tmp==null){
			throw new Exception("微信充值回调地址");
		}
		return tmp;
	}
	
	/**
	 * 微信充值显示标题
	 * @return
	 * @throws Exception
	 */
	public static String getWXBody() throws Exception{
		String tmp = SystemParamsUtil.getStringParam("WX_BODY");
		if(tmp==null){
			throw new Exception("微信充值显示标题");
		}
		return tmp;
	}

	/**
	 * 图片路径文件夹
	 * @return
	 * @throws Exception
	 */
	public static String QR_IMAGE_PATH() throws Exception{
		String tmp = SystemParamsUtil.getStringParam("QR_IMAGE_PATH");
		if(tmp==null){
			throw new Exception("图片路径文件夹");
		}
		return tmp;
	}
	
	/**
	 * 司机完成单笔结算金额
	 * @return
	 * @throws Exception
	 */
	public static int SETTLE_DRIVER_MONEY() throws Exception{
	    int tmp = SystemParamsUtil.getIntParam("SETTLE_DRIVER_MONEY");
		if(tmp==StaticData.no_param){
			throw new Exception("司机送单结算金额");
		}
		return tmp;
	}
	
	/**
	 * 单笔订单价格
	 * @return
	 * @throws Exception
	 */
	public static int ORDDER_PRICE() throws Exception{
	    int tmp = SystemParamsUtil.getIntParam("ORDDER_PRICE");
		if(tmp==StaticData.no_param){
			throw new Exception("司机送单结算金额");
		}
		return tmp;
	}
}